/*
 * cm_bit.h
 *
 *  Created on: 2014-4-21
 *      Author: Kise
 */

#ifndef CM_BIT_H_
#define CM_BIT_H_

static inline int bit_seted(unsigned char ch, unsigned bit)
{
	if (bit >= 8)
		return -1;
	else
		return (ch & ((unsigned char)1 << bit));
}

static inline int bitof0(int number)
{
	int ret = sizeof(int) << 3;
	int i;
	for(i = 0; i < sizeof(int) << 3; i++) {
		if(number & (0x1 << i))
			ret--;
	}
	return ret;
}

#endif /* CM_BIT_H_ */
